function parseParam(url) {
  const paramsStr = /.+\?(.+)$/.exec(url)[1]
  const paramsArr = paramsStr.split('&')
  const paramsObj = {}
  paramsArr.forEach(param => {
    if (/=/.test(param)) {
      let [key, value] = param.split('=')
      value = decodeURIComponent(value)
      if (paramsObj.hasOwnProperty(key)) {
        paramsObj[key] = [].concat(paramsObj[key], value)
      } else {
        paramsObj[key] = value
      }
    } else {
      paramsObj[param] = true
    }
  })
  return paramsObj
}
let url = 'https://example.com/page?name=John&age=30&city=New%20York'
console.log(parseParam(url))